﻿@page "/"

<Button Text="全部开启" OnClick=StartAllService ButtonType=ButtonType.Button Size=Size.ExtraSmall></Button>

<RealTable @ref="realTable" TItem="TaskThreadView" Items=ServiceControlCenter.Services>
    <TableColumns>
        <RealTableColumn @bind-Field="@context.ServiceName" Text="服务名称"></RealTableColumn>
        <RealTableColumn @bind-Field="@context.Interval" Text="时间间隔"></RealTableColumn>
        <RealTableColumn @bind-Field="@context.State" Text="状态">
            <Template Context="value">
                <Switch Value="@value.Value" OnColor="Color.Info" OnText="开启" OffText="关闭" IsDisabled=true></Switch>
            </Template>
        </RealTableColumn>
        <RealTableColumn @bind-Field="@context.IsRuning" Text="执行状态">
            <Template Context="value">
                @if (value.Value)
                    {
                <Badge Color="Color.Info">正在执行</Badge>
                    }
                    else
                    {
                <Badge Color="Color.Secondary">空闲中</Badge>
                    }
            </Template>
        </RealTableColumn>
        <RealTableColumn @bind-Field="@context.StartDatetime" Text="开始时间">
            <Template Context="value">
                @value.Value.ViewDateTime()
            </Template>
        </RealTableColumn>
        <RealTableColumn @bind-Field="@context.EndDateTime" Text="结束时间">
            <Template Context="value">
                @value.Value.ViewDateTime()
            </Template>
        </RealTableColumn>
        <RealTableColumn @bind-Field="@context.Id" Text="操作">
            <Template Context="value">
                @if (value.Row.State)
                    {
                <TableCellButtonItem Text="关闭" Color="Color.Secondary" Item=value.Row IsAsync=true OnClickCallbackItem=OnStop  ButtonType=ButtonType.Button Size=Size.ExtraSmall></TableCellButtonItem>

                    }
                    else
                    {
                <TableCellButtonItem Text="开启" Color="Color.Info" Item=value.Row IsAsync=true  OnClickCallbackItem=OnStart ButtonType=ButtonType.Button Size=Size.ExtraSmall></TableCellButtonItem>
                    }
            </Template>
        </RealTableColumn>
    </TableColumns>
</RealTable>


@code
{




}